

var app = getApp();
Page({
  data: {
    logs: [],
    collection_num: '0',   //查询收藏夹的条数
    browseNum: '0',//查询浏览记录的条数
    recommedarr: [

    ],
    avatarUrl: 'https://wagoxcx.oss-cn-beijing.aliyuncs.com/Ele_safe/54becd23b63505577c19203618423fd.png',
    eledata: {
      zongJifen: '-',
      todayJifen: '-',
      usedJifen: '-',
      grade: '初级电工',
      jifen: '-'
    }
  },
  onLoad: function () {



  },
  onShow: function () {
    this.getpersonalData();
    this.getpersonEle();
    var vm = this;
    wx.request({
      url: getApp().globalData.baseUrl + '/wago/product/selectJifenProdect',
      method: 'post',
      data: {
        "currentPage": 1,
        "pageSize": 10,
        "queryString": ""
      },
      success: function (res) {
        vm.setData({
          recommedarr: res.data.rows
        })
      }
    })
  },
  getpersonalData: function () {
    var that = this;
    wx.request({
      url: getApp().globalData.baseUrl + '/wago/user/selectByOpenid',
      data: {
        openid: getApp().globalData.openid
      },
      method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
      // header: {}, // 设置请求的 header
      success: function (res) {
        // console.log('海报',res.data.data)
        // success
        if (res.data.flag) {
          that.setData({
            avatarUrl: res.data.data.headimgurl,
          })
        }
      },
      fail: function () {
        // fail
      },
      complete: function () {
        // complete
      }
    })
  },
  getpersonEle: function () {
    var that = this;
    wx.request({
      url: getApp().globalData.baseUrl + '/wago/jifen/selectById',
      data: {
        userid: getApp().globalData.openid
      },
      method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
      // header: {}, // 设置请求的 header
      success: function (res) {
        // console.log('海报',res.data.data)
        // success
        if (res.data.flag) {
          that.setData({
            eledata: res.data.data,
          })
        }
      },
      fail: function () {
        // fail
      },
      complete: function () {
        // complete
      }
    })
  },
  login: function () {
    wx.navigateTo({
      url: "/pages/login/login"
    })
  },

  Tosign: function () {
    wx.navigateTo({
      url: "/pages/signIn/signIn"
    })
  },
  toscoreStore: function () {
    wx.navigateTo({
      url: "/pages/electricdetails/electricdetails"
    })
  },
  toinvitefriends: function () {
    wx.navigateTo({
      url: '/pages/invitefriends/invitefriends',
    })
  },
  Toexchange: function () {
    if (getApp().globalData.openid) {
      wx.navigateTo({
        url: "/pages/myexchange/myexchange"
      })
    } else {
      wx.showToast({
        title: '请先登录！',
        duration: 2000,
        icon: 'none'
      });
    }

  },
  ToRule: function () {
    wx.navigateTo({
      url: "/pages/ruleExplation/ruleExplation"
    })
  },
  ToWillChange: function (e) {
    if (getApp().globalData.openid) {
      wx.navigateTo({
        url: "/pages/willExchange/willExchange?item=" + JSON.stringify(e.currentTarget.dataset.item)
      })
    } else {
      wx.showToast({
        title: '请登录后再兑换！',
        duration: 2000,
        icon: 'none'
      });
    }

  },


})


